home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8438 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: s02.pavilion.co.uk!usenet
  2. From: AJRobb@pavilion.co.uk (Andy J Robb)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: dereferencing pointer to incomplete type
  5. Date: Mon, 04 Mar 1996 06:52:45 GMT
  6. Organization: Pavilion Internet plc
  7. Message-ID: <4he3ud$str@s02.pavilion.co.uk>
  8. References: <1996Mar3.040741.27234@dcs.warwick.ac.uk>
  9. NNTP-Posting-Host: poolc19.pavilion.co.uk
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. D.C.Molero@dcs.warwick.ac.uk (Daniel Castillo Molero) wrote:
  13.  
  14.  
  15. >Hi everybody.
  16. >I wonder if anybody can help me to debug the short code below.
  17. >It is supposed to calculate the area of a polygon, but when I compile
  18. >it with  gcc program.c, it gives me the following errors,
  19.  
  20. >program.c: In function `calc_area':
  21. >program.c:22: warning: assignment from incompatible pointer type
  22. >program.c:24: dereferencing pointer to incomplete type
  23. >program.c:24: dereferencing pointer to incomplete type
  24. >program.c:26: warning: assignment from incompatible pointer type
  25.  
  26.  
  27. >which I don't understand at all.
  28.  
  29. >I would appreciate very much any sort of help.
  30.  
  31. >------------------
  32.  
  33. >struct polygon
  34. >{
  35. >  int tried;
  36. >  double x, y;
  37. >  int dir, numtimes, conv;
  38. >  struct polyg *next;
  39.  
  40. Probably should be:
  41.   struct polygon *next;
  42.  
  43. >};
  44.  
  45.  
  46. >void triang(double a0, double a1, double b0, double b1, double c0, \
  47. >            double c1, double* result) {
  48. >  *result = a0 * b1 - a1 * b0 + \
  49. >            a1 * c0 - a0 * c1 + \
  50. >            b0 * c1 - c0 * b1;
  51. >}
  52.  
  53. >void calc_area(struct polygon* polyg, double* area) {
  54. >struct polygon* p;
  55. >double result;
  56. >p = polyg->next;
  57. >while (p->next != 0) {
  58. >  triang(polyg->x, polyg->y, p->x, p->y, (p->next)->x, (p->next)->y, &result);
  59. >  *area = *area + result;
  60. >  p = p->next;
  61. >}
  62. >}
  63. >-- 
  64. >* Daniel Castillo.  danmol@dcs.warwick.ac.uk *
  65.  
  66.  
  67.  
  68. -----BEGIN PGP PUBLIC KEY BLOCK-----
  69. Version: 2.6.2i
  70.  
  71. mQCNAy/MpRwAAAEEAOt6uBYqT8yv9EmqNhK8m6v+bYi8QjnGW3Bo6iU1gsMj5pa6
  72. MHgq99c8deADbE3cbJ6uZS9v5pZE3WCf6HCQjlB5iULA5RZzMdAumd/WUzuL9UT3
  73. B44D9EqqFIL79FlYb56v4oKFqFp1/J2bIpYUwnUvabGzGjdLrpPl4P16x9sNAAUR
  74. tCNBbmR5IEogUm9iYiA8QUpSb2JiQHBhdmlsaW9uLmNvLnVrPrQhQW5keSBSb2Ji
  75. IDxBSlJvYmJAcGF2aWxpb24uY28udWs+
  76. =/wVD
  77. -----END PGP PUBLIC KEY BLOCK-----
  78.  
  79.